home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / TreeView / Line.m < prev    next >
Encoding:
Text File  |  1995-04-12  |  976 b   |  45 lines

  1. //        Written by Don Yacktman Copyright (c) 1994 by Don Yacktman.
  2. //                Version 1.0.  All rights reserved.
  3. //
  4. //        This notice may not be removed from this source code.
  5. //
  6. //    This program is included in the MiscKit by permission from the author
  7. //    and its use is governed by the MiscKit license, found in the file
  8. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  9. //    for a list of all applicable permissions and restrictions.
  10. //    
  11.  
  12.  
  13. #import "Line.h"
  14.  
  15. @implementation Line
  16.  
  17. - setStart:(NXPoint *)s end:(NXPoint *)e
  18. {
  19.     start.x = s->x;
  20.     start.y = s->y;
  21.     end.x = e->x;
  22.     end.y = e->y;
  23.     return self;
  24. }
  25.  
  26. - render
  27. {
  28.     PSmoveto(start.x, start.y);
  29.     PSlineto(end.x, end.y);
  30.     PSstroke();
  31.     return self;
  32. }
  33.  
  34. - renderIfInRect:(const NXRect *)aRect
  35. {
  36.     NXRect tempRect = { { MIN(start.x, end.x), MIN(start.y, end.y) },
  37.         { MAX(ABS(start.x-end.x), 0.001), MAX(ABS(start.y-end.y), 0.001) } };
  38.     if (NXIntersectsRect(aRect, &tempRect)) {
  39.         [self render];
  40.     }
  41.     return self;
  42. }
  43.  
  44. @end
  45.